/**
 * Created by kosmoknot on 8/25/2014.
 */
var site = angular.module("site", [
    'ngRoute'
]);

site.controller("SiteController", ['$scope', '$routeParams', '$http', function ($scope, $routeParams, $http) {

    $scope.email="";
    $scope.username="";
    $scope.password="";

    $scope.loginError = false;

    $scope.showCategoryId = 0;
    $scope.showCategory = function ( num )
    {
        $scope.showCategoryId = num;
    }
    $scope.hideCategories = function ()
    {
        $scope.showCategoryId = 0;
    }

    $scope.getCreator = $scope.getDemo = function ()
    {
        location.href = 'creator.html#/home/5348024557502464';
    }

    $scope.getDemo = function ()
    {
        location.href = 'user.html#/home/5348024557502464';
    }

    $scope.loginUser = function ()
    {
        location.href = 'user.html#/home/5348024557502464';
        return;

        $scope.loginError = false;
        $http.get('http://localhost:3001/LoginUser?email=' + $scope.email + '&name='+ $scope.username + '&password=' + $scope.password)
            .success(function(data) {
                string = data.toLowerCase();
                if ( string.search( "error" ) >= 0 ) {
                    $scope.loginError = true;
                } else {
                    location.href = 'user.html#/home/' + data;
                }
            })
            .error(function(data) {
               $scope.loginError = true;
            }
        );
    }
}]);
